package com.study.config;

import org.springframework.amqp.core.ReturnedMessage;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Configuration;

//import javax.annotation.PostConstruct;

/**
 * 配置消息转换器
 */
public class MqConfig {
//    private final RabbitTemplate rabbitTemplate;
//
//    public MqConfig(RabbitTemplate rabbitTemplate) {
//        this.rabbitTemplate = rabbitTemplate;
//    }
//
//    @PostConstruct  //在注入rabbitTemplate依赖后执行
//    public void init(){
//        rabbitTemplate.setReturnsCallback(new RabbitTemplate.ReturnsCallback() {
//            @Override
//            public void returnedMessage(ReturnedMessage returned) {
//                log.error("触发return callback,");
//                log.debug("exchange: {}", returned.getExchange());
//                log.debug("routingKey: {}", returned.getRoutingKey());
//                log.debug("message: {}", returned.getMessage());
//                log.debug("replyCode: {}", returned.getReplyCode());
//                log.debug("replyText: {}", returned.getReplyText());
//            }
//        });
//    }
}